import fetch from '../util/fetch'

/**
 * api的核心执行方法
 * para：参数
 * url：对应的接口名
 * type：请求方式，默认成post请求
 */

let go = (para = {}, url = '', type = 'POST') => fetch(type, url, para);


var checkneedauth = () => fetch('GET', '/v1/un/checkneedauth', {});


var checkneedauth1 = '/v1/un/checkneedauth';

var checkneedauthtest = '/v1/un/checkneedauthtest';


var auth = () => fetch('GET', '/v1/un/auth', {});



var checkpayneedauth = (pay_company_code) => fetch('GET', '/v1/un/checkpayneedauth', {pay_company_code});
var checkpayneedauth1 = '/v1/un/checkpayneedauth';

var checkcashneedauth = () => fetch('GET', '/v1/un/checkcashneedauth', {});
var checkcashneedauth1 = '/v1/un/checkcashneedauth';




var payauth = () => fetch('GET', '/v1/un/payauth', {});


var getWXConfigInfo = (url, pay_company_code) => fetch('POST', '/v1/wn/configinfo', { url, pay_company_code });


var wxCreateOrder = (code, pay_company_code) => fetch('POST', '/v1/wn/createorder', { code, pay_company_code });


/**
 * 判断用户是否需要授权
 */

var isNeedAuthorization = () => fetch('GET', '/Api/Api/is_redis_company', {});



/**
 * 判断用户是否需要授权
 */

var getPayInfo = () => fetch('GET', '/Api/Api/is_pay_info', {});



/**
 * 测试环境模拟登录
 */

var simulationLogin = () => fetch('GET', '/Api/Api/mn_login', {});



var mnlogin = () => fetch('GET', '/v1/un/mnlogin', {});

/**
 * 首页数据	
 */

var homePageData = () => fetch('GET', '/api/uc/wc/newProductService/homePage', {});

var homePageData1 = '/api/uc/wc/newProductService/homePage';


/**
 * 商城配置	
 */

var shopConfig = () => fetch('GET', '/api/us/wc/configure/wxconfigureinfo', {});


/**
 * 分销中心数据
 */

var sellerCenterData = () => fetch('GET', '/api/uc/wc/newAccountService/moduleCount', {});


/**
 * 产品详情
 */

var productDetails = (product_code) => fetch('GET', '/api/uc/wc/newProductService/wxProductInfo', {
	product_code,
});


var productDetails1 = '/api/uc/wc/newProductService/wxProductInfo';


/**
 * 产品型号
 */

var productModel = (product_code, openid) => {
	var para = {
		product_code,
	}
	if(openid !== undefined){
		para['openid'] = openid;
	}
	return fetch('GET', '/api/uc/wc/newProductService/attrList', para);
};


/**
 * 货架列表
 */

var goodsList = (openid) => fetch('GET', '/api/uc/wc/newProductService/distributionProductList', {
	openid,
});


/**
 * 产品列表
 */

var productList = (type_code, name) => {
	var para = {};
	if(type_code !== undefined){
		para['type_code'] = type_code;
	}
	if(name !== undefined){
		para['name'] = name;
	}
	return fetch('POST', '/api/us/wc/newproduct/wxproductlist', para);
};


/**
 * 下单
 */

var placeOrder = (sale_code, attr_id, num, mobile, total_price, name, tour_date, cardno, openid, remark) => {
	var para = {
		sale_code,
		attr_id,
		num,
		mobile,
		total_price,
		name,
		remark,
	};
	if(tour_date !== undefined){
		para['tour_date'] = tour_date;
	}
	if(cardno !== undefined){
		para['cardno'] = cardno;
	}
	if(openid !== undefined){
		para['openid'] = openid;
	}
	return fetch('POST', '/api/uc/wc/newProductOrderService/createOrder', para);
};


/**
 * 订单列表
 */

var getOrderList = (pageNo, pageSize, pay_state) => fetch('GET', '/api/us/wc/newproductorder/wxorderlist', {
	pageNo,
	pageSize,
	pay_state,
});


/**
 * 订单列表
 */

var getOrderDetails = (code) => fetch('GET', '/api/us/wc/newproductorder/orderinfo', {
	code,
});


/**
 * 订单中票列表
 */

var getOrderTicketList = (order_code) => fetch('GET', '/api/us/wc/newproductorder/ticketlist', {
	order_code,
});


/**
 * 退票
 */

var backOrder = (order_code, back_count) => fetch('POST', '/api/uc/wc/newProductOrderService/createBackOrder', {
	order_code,
	back_count,
});



/**
 * 我的账户数据
 */

var accountData = (level_code) => fetch('GET', '/api/uc/wc/productOrderStatisticsService/profitPrice', {
	level_code,
});


/**
 * 预计收益明细
 */

var getPreIncomeDetail = () => fetch('GET', '/api/us/wc/newproductorder/estimatelist', {});


/**
 * 实际收益明细
 */

var getIncomeDetail = (level_code) => fetch('GET', '/api/us/wc/newusedrecord/incomelist', {
	level_code,
});



/**
 * 提现
 */

var withdrawCash = (price) => fetch('POST', '/api/uc/wc/newAccountService/createWithdrawals', {
	price,
});


/**
 * 提现明细
 */

var getCashDetails = (code) => fetch('GET', '/api/us/wc/newaccount/accountloglist', {
	code,
});


/**
 * 销售统计
 */

var getStatistics = (level_code, fx_level) => fetch('GET', '/api/us/wc/newusedrecord/goodsstatisticslist', {
	level_code,
	fx_level,
});



/**
 * 分销商销量排名
 */

var sellerRankings = (level_code, fx_level, sale_code, attr_id) => fetch('POST', '/api/us/wc/newusedrecord/salesrankinglist', {
	level_code,
	fx_level,
	sale_code,
	attr_id,
});


/**
 * 用户信息
 */

var userData = () => fetch('GET', '/api/uc/wc/userWxSkService/memberlevel', {});

//var userData = '/api/uc/wc/userWxSkService/memberlevel';


/**
 * 绑定粉丝
 */

var bindFans = (openid) => fetch('POST', '/api/us/wc/myfans/create', {
	openid,
});

//绑定粉丝
// var bindFans = '/api/us/wc/myfans/create';
//粉丝信息
var myFansInfo = '/api/us/wc/myfans/myfaninfo';


/**
 * 粉丝列表
 */

var getFansList = (pageNo, pageSize) => fetch('POST', '/api/us/wc/myfans/myfanlist', {
	pageNo,
	pageSize,
});



/**
 * 申请分销商
 */

var applySeller = (user_base) => fetch('POST', '/api/uc/wc/userWxService/createApplyDistributor', {
	user_base,
});


/**
 * 未审核分销商列表
 */

var unSellerList = (nickname) => fetch('POST', '/api/us/wc/applydistributor/list', {
	nickname,
});


/**
 * 已审核分销商列表
 */

var sellerList = (nickname, level_code) => fetch('POST', '/api/us/wc/userwxsk/mydistributionlist', {
	nickname,
	level_code,
});



/**
 * 同意/拒绝 成为分销商
 */

var agreeSeller = (create_by, state) => fetch('POST', '/api/uc/wc/userWxService/createfxlevel', {
	create_by,
	state,
});



/**
 * 创建邮寄信息
 */

var createMail = (lxr_name, lxr_mobile, lxr_address, state) => fetch('POST', '/api/us/wc/mymail/create', {
	lxr_name,
	lxr_mobile,
	lxr_address,
	state,
});



/**
 * 修改邮寄信息
 */

var updateMail = (id, lxr_name, lxr_mobile, lxr_address, state, del_flg) => fetch('POST', '/api/uc/wc/myMailService/updateMail', {
	id,
	lxr_name,
	lxr_mobile,
	lxr_address,
	state,
	del_flg,
});


/**
 * 邮寄列表
 */

var mailList = (state) => fetch('GET', '/api/us/wc/mymail/mymaillist', {
	state,
});



//收藏
var createCollection = '/api/us/wc/mycollection/create';
//取消收藏
var deleteCollection = '/api/us/wc/mycollection/delete';
//收藏列表
var collectionList = '/api/us/wc/mycollection/list';


/**
 * 票机登录
 */

var destroyLogin = '/wdapi/sc/queryService/login';


/**
 * 验票
 */

var queryByCode = '/wdapi/sc/queryService/byCode';


/**
 * 核销
 */

var destroyByCode = '/wdapi/sc/destoryService/updateByCode';


//注册成功
const setregistersuccess = '/v1/ua/setregistersuccess';



//用加密订单编号查询订单详情.
const jmorderinfo = '/api/us/wc/newproductorder/jmorderinfo';

//核销统计
//device,start_time,end_time
const getDeviceReceliptCountList = '/api/us/wc/devicequerycount/getDeviceReceliptCountList';
//按型号统计
const getDeviceReceliptCountAttrList = '/api/us/wc/devicequerycount/getDeviceReceliptCountAttrList';
//居游票列表
const juyouTicketList = '/api/uc/wc/newProductOrderService/wdorderticketlist';

//分销查询接口
const fxorderlist = '/api/us/wc/newproductorder/fxorderlist';

//解除分销商资格。
const updatefxlevel = '/api/uc/wc/userWxSkService/updatefxlevel';

//卡激活，create_type=jihuo,from_app_id=qunmeng,mobile,cardno,card_password,remark
const activation = '/api/uc/cdc/userCardProductOrderService/createProductOrderBuyCardNo';


// -------- 测试工具接口 ------------------------- //
const getCookies = '/v1/un/getcookies';
const clearinfo = '/v1/un/clearinfo';


// -------- 测试工具接口 ------------------------- //


export {
	go,

	
	checkneedauth,
	checkneedauth1,
	checkneedauthtest,
	auth,
	checkpayneedauth,
	checkpayneedauth1,

	checkcashneedauth,
	checkcashneedauth1,
	payauth,

	isNeedAuthorization,
	getPayInfo,

	mnlogin,

	getWXConfigInfo,
	wxCreateOrder,

	simulationLogin,
	homePageData,
	homePageData1,
	shopConfig,
	sellerCenterData,
	productDetails,
	productDetails1,
	productModel,
	goodsList,
	productList,
	placeOrder,
	getOrderList,
	getOrderDetails,
	getOrderTicketList,
	backOrder,
	accountData,
	getPreIncomeDetail,
	getIncomeDetail,
	withdrawCash,
	getCashDetails,
	getStatistics,
	sellerRankings,
	userData,
	//userData1,
	bindFans,
	myFansInfo,
	getFansList,
	applySeller,
	unSellerList,
	sellerList,
	createMail,
	updateMail,
	mailList,
	agreeSeller,

	createCollection,
	deleteCollection,
	collectionList,

	setregistersuccess,

	destroyLogin,
	queryByCode,
	destroyByCode,

	jmorderinfo,

	getDeviceReceliptCountList,
	getDeviceReceliptCountAttrList,

	juyouTicketList,
	getCookies,
	clearinfo,

	fxorderlist,
	updatefxlevel,

	activation,
}